package com.sdap2.vo;

import com.sdap2.entity.Device;
import com.sdap2.entity.enums.DeviceType;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class DeviceVO {
    private Long id;
    private String name;
    private String serialNumber;
    private DeviceType deviceType;
    private String deviceTypeName;
    private String unit;
    private String description;
    private Integer status;
    private Long greenhouseId;
    private String greenhouseName;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    private String MonitorUrl;
    
    public static DeviceVO fromEntity(Device device) {
        DeviceVO vo = new DeviceVO();
        vo.setId(device.getId());
        vo.setName(device.getName());
        vo.setSerialNumber(device.getSerialNumber());
        vo.setDeviceType(device.getDeviceType());
        vo.setDeviceTypeName(device.getDeviceType().getDescription());
        vo.setUnit(device.getUnit());
        vo.setDescription(device.getDescription());
        vo.setStatus(device.getStatus());
        vo.setGreenhouseId(device.getGreenhouse().getId());
        vo.setGreenhouseName(device.getGreenhouse().getName());
        vo.setCreateTime(device.getCreateTime());
        vo.setUpdateTime(device.getUpdateTime());
        vo.setMonitorUrl(device.getMonitorUrl());
        return vo;
    }
} 